<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>医生登录 - 哈尔滨信息工程学院医院门诊系统</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }

        .login-container {
            background-color: white;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
            width: 400px;
        }

        .login-header {
            text-align: center;
            margin-bottom: 25px;
        }

        .login-header h1 {
            color: #4CAF50;
            margin: 0;
        }

        .login-header p {
            color: #666;
            margin: 5px 0 0 0;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
        }

        .form-group input {
            width: 100%;
            padding: 12px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }

        .login-btn {
            width: 100%;
            padding: 12px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s;
        }

        .login-btn:hover {
            background-color: #45a049;
        }

        .back-link {
            display: block;
            text-align: center;
            margin-top: 20px;
            color: #2196F3;
            text-decoration: none;
        }

        .back-link:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <div class="login-header">
            <h1>医生登录</h1>
            <p>哈尔滨信息工程学院医院门诊系统</p>
        </div>
        <form id="loginForm">
            <div class="form-group">
                <label for="username">用户名:</label>
                <input type="text" id="username" name="username" placeholder="请输入用户名" required>
            </div>
            <div class="form-group">
                <label for="password">密码:</label>
                <input type="password" id="password" name="password" placeholder="请输入密码" required>
            </div>
            <button type="button" class="login-btn" onclick="login()">登录</button>
        </form>
        <a href="/hospital/index" class="back-link">返回首页</a>
    </div>

    <script src="/js/jquery.min.js"></script>
    <script>
        function login() {
            var username = $("#username").val();
            var password = $("#password").val();

            if (username == "" || password == "") {
                alert("请填写用户名和密码");
                return;
            }

            $.ajax({
                url: "/hospital/doctor/tologin",
                type: "POST",
                data: {
                    username: username,
                    password: password
                },
                success: function(data) {
                    if (data == 1) {
                        window.location.href = "/hospital/doctor/index";
                    } else {
                        alert("用户名或密码错误");
                    }
                },
                error: function() {
                    alert("系统错误，请稍后再试");
                }
            });
        }

        // 回车提交登录
        document.getElementById('password').addEventListener('keypress', function(e) {
            if (e.key === 'Enter') {
                login();
            }
        });
    </script>
</body>
</html>
